<template>
<view class="yajin">
	<view style="width: 650upx; margin: 61upx auto 0; text-align: left; font-size: 40upx; color: #333333;">退押金后</view>
	<view style="width: 650upx; margin: 28upx auto 0; text-align: left; font-size: 40upx; color: #333333;">您将无法使用电小童共享充电宝</view>
	<image src="/static/yajin1.png" style="display: block; width: 529upx; height: 137upx; margin: 140upx auto 0;"></image>
	<view @click="nextStep" style="margin: 170upx auto 0; width: 670upx; height: 105upx; line-height: 105upx; text-align: center; font-size: 30upx; background-color: #cecece; color: #333333;">
		确定退还押金
	</view>
	<view @click="goback" style="margin: 30upx auto 0; width: 670upx; height: 105upx; line-height: 105upx; text-align: center; font-size: 30upx; background-color: #18a3dc; color: #FFFFFF;">
		算了
	</view>
	<view style="height: 100upx;"></view>
</view>
</template>

<script>
import { HTTP } from '../../http.js';
let http = new HTTP;
export default {
	data() {
		return {
		}
	},
	methods: {
		nextStep(){	
			uni.showLoading({ title: '加载中' });
			this.getRight(
				()=>http.request({
					url: `borrow/refundDeposit?a=a`,
					method: 'post',
					success: (res)=>{		
						uni.hideLoading();
						console.log(res,'钱包');
						uni.navigateBack({ delta: 2, success: ()=>uni.showToast({ icon: 'none', title: '退还成功，请耐心等待押金到账！', duration: 2000 }) });		
					},
					fail: ()=>uni.hideLoading()
				})
			);
		},
		getRight(cb){	
			let user = uni.getStorageSync('user');
			http.request({
				url: `orderFormController/notPayOrder?userId=${user.userId}`,
				method: 'get',
				success: (res)=>{
					if(res.dataList&&res.dataList.orderId){
						uni.hideLoading();
						let orderId=res.dataList.orderId;
						uni.showModal({
							title: '提示',
							content: '检测到尚有订单未完成，是否立即查看该订单详情！',
							success: (res)=>{
								if(res.confirm){
									uni.navigateTo({ url: 'dingdanxiangqing?id='+orderId });
								}
							}
						});
					}else{
						if(cb) cb();
					}
				},
				fail: ()=>uni.hideLoading()
			});	
		},
		goback(){
			uni.navigateBack({ delta: 2 });					
		}
	}
}
</script>

<style>
.yajin {
	height: 100vh;
	position: relative;
	background: #fff;
	overflow: auto;
}
</style>
